package com.keyancompany.zhongbaopingtai.fragment;


import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.keyancompany.zhongbaopingtai.R;
import com.keyancompany.zhongbaopingtai.adapter.IFragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;

/**
 * Created by firefox on 2016/5/31.
 */
public class FindFragment extends BaseFragment {

    public static final String TYPE = "type";

    public static final int TYPE_PEOPLE = 1;
    public static final int TYPE_PROJECT = 2;

    @Bind(R.id.tabLayout)
    TabLayout tabLayout;

    @Bind(R.id.complaint_viewpager)
    ViewPager complaintViewpager;


    @Override
    public int getContentViewId() {
        return R.layout.fragment_find;
    }

    @Override
    public void setUpViews() {
        tabLayout.addTab(tabLayout.newTab().setText("Tab 1"));
        tabLayout.addTab(tabLayout.newTab().setText("Tab 2"));
        List<Fragment> tcf = new ArrayList<>();
        tcf.add(FindItemPeopleFragment.newInstance(TYPE_PEOPLE));
        tcf.add(FindItemProjectFragment.newInstance(TYPE_PROJECT));
        IFragmentPagerAdapter pagerAdapter = new IFragmentPagerAdapter(getChildFragmentManager(), tcf);
        pagerAdapter.setTitles(new String[]{"找人", "找项目"});
        complaintViewpager.setAdapter(pagerAdapter);
        tabLayout.setupWithViewPager(complaintViewpager);
        tabLayout.setTabMode(TabLayout.MODE_FIXED);
    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);

    }
}
